package chapter07

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test11_Tuple
 * Package: chapter07
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-07-06
 *          Time: 15:35
 */

object Test11_Tuple {

  def main(args: Array[String]): Unit = {
    //元组 就是元素的集合
    //创建 最大容量是23 最多下标到22
    val tuple1:(String,Int,Char,Boolean) = ("hello",100,'a',true)

    println(tuple1)

    //访问数据
    println(tuple1._1)
    println(tuple1._2)

    //通过元素索引 从0开始 获取指定位置的元素
    println(tuple1.productElement(1))

    //遍历 迭代器遍历
    for (elem <-tuple1.productIterator){
      println(elem)
    }
    //嵌套
    val num = (12,0.2,"hello",(123,"scala"))
    println(num)
    //获取位置 从1开始
    println(num._4._2)


  }

}
